<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableClientValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'_password2'); ?>
		<?php echo $form->passwordField($model,'_password2',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'_password2'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'first_name'); ?>
		<?php echo $form->textField($model,'first_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'first_name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'last_name'); ?>
		<?php echo $form->textField($model,'last_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'last_name'); ?>
	</div>

	<div class="row buttons">
		<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
		<?php  echo CHtml::ajaxSubmitButton(
			$model->isNewRecord ? 'Create' : 'Save',
			$this->createUrl('/user/ajaxreg'),
			array(
				'dataType'=>'json',
				'success'=>'function(transport){ successRegistration(transport) }'
			)); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<script type='text/javascript'>
	/* <![CDATA[ */
	
		function successRegistration(transport){
			if(transport) {
				if(transport.form) {
					$('#registration-dialog').html(transport.form);
				}

				if(transport.success) {
					alert(transport.success);
					$('#registration-dialog').dialog('close');
				}
			}
		}	
	
	/* ]]> */
</script>